<!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>配种</title>
    <link href="../css/mui.min.css" rel="stylesheet" type="text/css">
    <link href="../css/home.page.css" rel="stylesheet" />
    <link href="../bootstrap-select/bootstrap-select.css" rel="stylesheet">
    <link href="../css/bootstrap.min.css" rel="stylesheet" >
	<link href="../css/mui.picker.min.css" rel="stylesheet" >
    <script charset="UTF-8" src="../js/jquery.min.js"></script>
    <script charset="UTF-8" src="../js/config.js"></script>
    <script charset="UTF-8" src="../js/core.js"></script>
    <script charset="UTF-8" src="../js/cipher-core.js"></script>
    <script charset="UTF-8" src="../js/tripledes.js"></script>
    <script charset="UTF-8" src="../js/mode-ecb.js"></script>
    <script charset="UTF-8" src="../js/zepto.min.js"></script>
    <script charset="UTF-8" src="../js/spin.min.js"></script>
    <script charset="UTF-8" src="../js/mui.min.js"></script>
    <script charset="UTF-8" src="../js/testActivityName.js"></script>
    <script charset="UTF-8" src="../js/simple.tool.js"></script>
	<script charset="UTF-8" src="../js/mui.picker.min.js"></script>
    <style>		
        label{
            text-align: right;
        }
        .btn-default{
            border-color: snow;
        }
        .form-control{
            -webkit-box-shadow: inset 0 0px 0px rgba(0,0,0,.075);
        }
        .form-group{
            border-bottom: 1px solid #f6f6f6;max-width: 720px;height: 55px;
        }
    </style>
</head>
<body class="white-bg" >
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" style="width: 95%;" id="form-breeding-add" target="ifr">
        <div class="form-group" style="margin-bottom: 0px;border-bottom: 0px solid #f6f6f6;">
            <div class="head-jnx" onclick="record()">
                <img src="../img/fanhui@3x.png" />
                <p>配种</p>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">耳号：<span style="color: red">*</span></label>
            <div class="col-xs-7">
                <select   name="cowId"  class="selectpicker form-control m-b" data-live-search="true"  data-size="10"  id="overbit"  title="选择耳号" required >
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">配种日期：<span style="color: red">*</span></label>
            <div class="col-xs-7">
                <div class="input-group date">
                    <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                    <input id="breedingDate" type="text" onfocus=this.blur() onclick="dtPicker('breedingDate')">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">冻精编号：</label>
            <div class="col-xs-7">
                <select name="semenCode" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;"  id="semenCode" onchange="getSemenCode()">
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">配种员：</label>
            <div class="col-xs-7">
                <select name="breeder" id="breeder" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;">

                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">冻精类型：</label>
            <div class="col-xs-7">
                <input  id="semenType" class="form-control" type="text" readonly="readonly" >
                <input name="semenType" id="semenTypeValue" class="form-control" type="text" readonly="readonly" style="display: none">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">配种结果：</label>
            <div class="col-xs-7">
                <select name="breedingResultId" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" id="breedingResultId">

                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">怀孕进度：</label>
            <div class="col-xs-7">
                <select name="pregnancyScheduleId" style="/* display: table-cell; */vertical-align: middle;text-align: left;width: 100%;" id="pregnancyScheduleId">

                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">冻精使用量：</label>
            <div class="col-xs-7">
                <input name="semenUseNumber" class="form-control" type="text" placeholder="请输入">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">配种评注：</label>
            <div class="col-xs-7">
                <input name="breedingComment" class="form-control" type="text" placeholder="请输入" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-4 control-label">备注：</label>
            <div class="col-xs-7">
                <input name="remake" class="form-control" type="text" placeholder="请输入" >
            </div>
        </div>
        <div class="form-group">
            <div style="width: 320px; margin: auto;">
                <div class="quxiao-btn" style="margin-right: 15px;" onclick="record()">取消</div>
                <input type="submit" value="保存信息" class="quxiao-btn" style="background: #0078fb; color: #FFFFFF;border-radius: 55px;" >
                <div class="clear"></div>
            </div>
        </div>
    </form>
</div>
<iframe name='ifr' id="ifr" style='display: none;'></iframe><!--表单提交防止刷新-->
<script src="../js/bootstrap.min.js"></script>
<script src="../bootstrap-select/bootstrap-select.js"></script>
<script type="text/javascript">
	var mapS={}
	mapS.url="getsynestrusdata";
	var overbitList=ajaxRequestPostS(mapS);
    window.onload=breedLoad();
	var i = setTimeout(function(){
		overbitList = JSON.parse(localStorage.getItem('getsynestrusdata'));
		console.log(overbitList)
	    if(overbitList != 0){
			loadSelect('overbit',overbitList,'cow_id','overbit');//耳号
			$('.selectpicker').selectpicker('refresh');
		}
	},900);
    function breedLoad() {//获得下拉数据
        var resultData = JSON.parse(localStorage.getItem('addbreeddata'));
        breedHtml(resultData.data);
		$("#breedingDate").val(getDateNow());
    }
    $("#form-breeding-add").submit(function () {
        map={};
        map=$('#form-breeding-add').serializeObject();
        map.url="addbreed";
        map.overbit=$("#overbit option:selected").text();
        var resultData=ajaxRequestPostSubmit(map);
        if (resultData.head.info == "增加成功") {
            setTimeout(function () {
                record();
            }, 1000);
        }
    });
    function record() {//返回记录
        window.location = "../记录.html";
    }
    function breedHtml(resultData) {//加载下拉
		var userName = resultData.realName;
     
        var breederList=resultData.breederList;
        loadSelect('breeder',breederList,'real_name','real_name',userName);//配种员
        var pregnancyScheduleList=resultData.pregnancyScheduleList;
        loadSelect('pregnancyScheduleId',pregnancyScheduleList,'code','name');//怀孕进度
        var breedingResultList=resultData.breedingResultList;//配种结果
        loadSelect('breedingResultId',breedingResultList,'code','name');
        var semenCodeList=resultData.semenCodeList;//冻精编号
        loadSelect('semenCode',semenCodeList,'semen_no','semen_no');
        $('.selectpicker').selectpicker('refresh');
    }
    function loadSelect(id,data,code,name,userName) {
        $("#"+id).html("");
        $("#"+id).append("<option value=''>请选择</option>");
        for (i=0;i<data.length;i++){//
			var str='';
			if(userName != null && data[i][name] == userName){
				str='<option value="'+data[i][code]+'" selected>'+data[i][name]+'</option>';
			}else{
				str='<option value="'+data[i][code]+'">'+data[i][name]+'</option>';
			}
            $("#"+id).append(str);
        }
    }

     function getSemenCode() {
        var semenCode =$("#semenCode").val();
        var map={}
        map.semenCode = semenCode;
        map.url="getSemenCode";
        var resultData=ajaxRequestPost(map);
        if(resultData.data.semenTypeList.length > 0){
            $("#semenType").val(resultData.data.semenTypeList[0].semen_type);
            $("#semenTypeValue").val(resultData.data.semenTypeList[0].code);
        }else{
            $("#semenType").val("");
            $("#semenTypeValue").val("");
        }
    }
	

</script>
</body>
</html>